package cn.jbolt.platform.globalconfig;

import cn.jbolt.core.api.JBoltApiBaseController;
import cn.jbolt.core.api.OpenAPI;
import cn.jbolt.core.api.httpmethod.JBoltHttpGet;
import cn.jbolt.core.base.JBoltGlobalConfigKey;
import cn.jbolt.core.cache.JBoltGlobalConfigCache;
import cn.jbolt.core.crossorigin.CrossOrigin;
import cn.jbolt.core.para.JBoltNoUrlPara;
import com.jfinal.aop.Before;
import com.jfinal.kit.Kv;

/**
 * 全局参数设置API Controller
 * 跨域
 */
@CrossOrigin
public class GlobalConfigApiController extends JBoltApiBaseController {

    /**
     * 获取版权信息和备案号
     */
    @Before(JBoltNoUrlPara.class)
    @OpenAPI
    @JBoltHttpGet
    public void copyrightAndApprove(){
        Kv config = Kv.create();
        String configValue = JBoltGlobalConfigCache.me.getConfigValue(JBoltGlobalConfigKey.JBOLT_DOMAIN_PUT_ON_RECORD_INFO);
        config.put("approveSn", configValue);
        configValue = JBoltGlobalConfigCache.me.getConfigValue(JBoltGlobalConfigKey.JBOLT_DOMAIN_PUT_ON_RECORD_LINK);
        config.put("approveLink", configValue);
        configValue = JBoltGlobalConfigCache.me.getConfigValue(JBoltGlobalConfigKey.SYSTEM_COPYRIGHT_COMPANY);
        config.put("copyright", configValue);

        configValue = JBoltGlobalConfigCache.me.getConfigValue(JBoltGlobalConfigKey.SYSTEM_COPYRIGHT_LINK);
        config.put("copyrightLink", configValue);

        renderJBoltApiSuccessWithData(config);

    }
}
